package com.huluobo.a2308douyindemo.home

import com.huluobo.a2308douyindemo.bean.HomeBannerBean
import com.huluobo.a2308douyindemo.bean.HomeBillBean
import com.huluobo.a2308douyindemo.bean.HomeGoodsBean
import com.huluobo.a2308douyindemo.bean.HomeNavBean
import com.huluobo.a2308douyindemo.mvvm.BaseViewModel
import com.huluobo.a2308douyindemo.net.ApiService
import com.huluobo.a2308douyindemo.net.Res
import com.huluobo.a2308douyindemo.utils.UnPeekLiveData
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 *  Created by LC on 2025/11/5.
 */
@HiltViewModel
class HomeViewModel @Inject constructor(private val apiService: ApiService) : BaseViewModel() {
    val getHomeBannerSuccess by lazy { UnPeekLiveData<Res<List<HomeBannerBean>>>() }
    fun getHomeBanner() {
        executeNetwork(
            { apiService.getHomeBanner() },
            getHomeBannerSuccess::setContentValue
        )
    }

    val getHomeNavSuccess by lazy { UnPeekLiveData<Res<List<HomeNavBean>>>() }
    fun getHomeNav() {
        executeNetwork(
            { apiService.getHomeNav() },
            getHomeNavSuccess::setContentValue
        )
    }

    val getHomeGoodsSuccess by lazy { UnPeekLiveData<Res<List<HomeGoodsBean>>>() }
    fun getHomeGoods() {
        executeNetwork(
            { apiService.getHomeGoodsInfo() },
            getHomeGoodsSuccess::setContentValue
        )
    }

    val getHomeBillSuccess by lazy { UnPeekLiveData<Res<List<HomeBillBean>>>() }
    fun getHomeBill() {
        executeNetwork(
            { apiService.getHomeBill() },
            getHomeBillSuccess::setContentValue
        )
    }
}